//**************************************************************************
//	Unit Test
//**************************************************************************
//**************************************************************************

#include "PlateLocalization.h"
#include "cv.h"
#include "highgui.h"
#include "cxtypes.h"
#include "DebugImage.h"
//	Mouse callback function
void MouseCallback(int event, int x, int y, int flags, void* param)
{
	if (event == CV_EVENT_LBUTTONDOWN)
	{
		IplImage *img = (IplImage *)param;
		uchar r = CV_IMAGE_ELEM(img, uchar, y, x * 3 + 0);
		uchar g = CV_IMAGE_ELEM(img, uchar, y, x * 3 + 1);
		uchar b = CV_IMAGE_ELEM(img, uchar, y, x * 3 + 2);
		printf("\n(%d, %d) : %u %u %u", x, y, r, g, b);
	}
}

void test(const char * str)
{
	IplImage *img = cvLoadImage(str,1);

	cvSetMouseCallback("Test", MouseCallback, img);

	PlateLocalization::Instance()->FindLicenseNumber(img);

	cvSetMouseCallback("Test2", MouseCallback, img);

	cvWaitKey();
	cvReleaseImage(&img);
	cvDestroyAllWindows();
}

//	Debug exe's entry point
int main(int argc, char** argv)
{
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test1.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test2.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test3.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test4.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test5.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test6.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test7.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test8.jpg");
	test("C:\\Technion\\Semester 6\\OS Project\\PlateLocalization\\PlateLocalization\\debug\\test9.jpg");
	return 0;
}
